// import { local } from 'shared/utils/func';
import * as HttpMethodEnum from './consts/HttpMethodEnum';
import * as ContentTypeEnum from './consts/ContentTypeEnum';

export default function processHeaders(method, headers = {}) {
  const contentType = {
    // 'Content-Type': ((method === HttpMethodEnum.POST || method === HttpMethodEnum.PUT) ? ContentTypeEnum.JSON : ContentTypeEnum.URL_ENCODED)
    'Content-Type': ContentTypeEnum.URL_ENCODED
  };

  const requestedWidth = {
    'X-Requested-With': 'XMLHttpRequest',
    'Access-Control-Allow-Origin': '*'
  };

  // const Authorization = {
  //   Authorization: local.getSession('Authorization')
  // };

  const finalHeaders = Object.assign({}, contentType, requestedWidth, headers);

  Object.keys(finalHeaders).forEach((key) => {
    if (typeof finalHeaders[key] === 'object') {
      finalHeaders[key] = JSON.stringify(finalHeaders[key]);
    }
  });

  return finalHeaders;
}
